package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.product.entity.BaseTrademark;
import com.atguigu.gmall.product.service.BaseTrademarkService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/product")
public class BaseTrademarkController {
    @Autowired
    BaseTrademarkService baseTrademarkService;
    @GetMapping("/baseTrademark/{pn}/{ps}")
    public Result baseTrademarkList(@PathVariable("pn") Long pn,
                                    @PathVariable("ps") Long ps){
        Page<BaseTrademark> page = new Page<>(pn,ps);
        Page<BaseTrademark> result = baseTrademarkService.page(page);

        return Result.ok(result);
    }
    @PostMapping("/baseTrademark/save")
    public Result save(@RequestBody BaseTrademark baseTrademark){
        baseTrademarkService.save(baseTrademark);
        return Result.ok();
    }
    @DeleteMapping("/baseTrademark/remove/{id}")
    public Result delete(@PathVariable("id")Long id){
        baseTrademarkService.removeById(id);
        return Result.ok();
    }
    @GetMapping("/baseTrademark/get/{id}")
    public Result get(@PathVariable("id")Long id){
        BaseTrademark byId = baseTrademarkService.getById(id);
        return Result.ok(byId);
    }
    @PutMapping("/baseTrademark/update")
    public Result update(@RequestBody BaseTrademark  trademark){
        baseTrademarkService.updateById(trademark);
        return Result.ok();
    }
}
